﻿
namespace CmdArgs.Validation.Options
{
    using CmdArgs.Settings;

    /// <summary>
    /// Validates whether the parameters' values are doubles.
    /// </summary>
    public sealed class DoubleOptionValidator : ValueValidatorTemplate
    {
        protected override ValidationResult Validate(string value, OptionSettings option)
        {
            double result;
            if (double.TryParse(value, out result))
            {
                return ValidationResult.GetValidResult();
            }
            else
            {
                string message = string.Format("Value {0} is not integer.", value);
                return new ValidationResult(new ValidationError(message, option));
            }
        }
    }
}
